﻿namespace Titan.FIS.LmsBalanceCollect
{
    public class DataExecSql
    {
        /// <summary>
        /// 插入CRI原始数据
        /// </summary>
        /// <param name="strValue1"></param>
        /// <param name="strValue2"></param>
        /// <param name="strID"></param>
        /// <param name="strErrInfo"></param>
        /// <returns></returns>
        public static int DoInsertCRICollectionData(int strDevId, string strAutoNo, string strTestCode,
            string SAMPLE_WEIGHT, string SAMPLE_COUNT, string CRI_WEIGHT, string CRI_COUNT, string CSR_WEIGHT, string CSR_COUNT, string CRI, string CSR, string REMARK,
            ref string strErrInfo)
        {
            var strSql = $@"INSERT INTO LMS_TESTDATA_CRI
                                  (CRI_ID,
                                   INSTRUMENT,
                                   AUTO_NO,
                                   TEST_CODE,
                                   SAMPLE_WEIGHT,
                                   SAMPLE_COUNT,
                                   CRI_WEIGHT,
                                   CRI_COUNT,
                                   CSR_WEIGHT,
                                   CSR_COUNT,
                                   CRI,
                                   CSR,
                                   REMARK,
                                   STATUS,
                                   TEST_USER,
                                   TEST_TIME)
                                VALUES
                                  (SYS_GUID(),
                                   {strDevId},
                                   '{strAutoNo}',
                                   '{strTestCode}',
                                   {SAMPLE_WEIGHT},
                                   {SAMPLE_COUNT},
                                   {CRI_WEIGHT},
                                   {CRI_COUNT},
                                   {CSR_WEIGHT},
                                   {CSR_COUNT},
                                   {CRI},
                                   {CSR},
                                   '{REMARK}',
                                   {0},
                                   '{Common.UserInfo.UserId}',
                                   SYSDATE)";
            
            var modelExecSql = Titan.DAS.Client.Data.DataHelper.Instance.ExecSql(Common.UserInfo.UserName, Common.UserInfo.UserPwd, strSql);
            if (modelExecSql.RSuccess) return modelExecSql.RAffectedRowNum;
            strErrInfo = @"保存失败" + "\n错误代码：" + modelExecSql.RStatuCode + "\n错误描述：" + modelExecSql.RStatuDesc + strSql;
            return 0;
        }
    }
}
